package chapter2.chapter2homework;

import java.util.ArrayList;
import java.util.Random;
import java.util.TreeSet;

public class question5 {
    public static void main(String[] args) {
        // 生成红色球号码
        TreeSet<Integer> redBalls = new TreeSet<>();
        Random random = new Random();
        while (redBalls.size() < 6) {
            int num = random.nextInt(33) + 1;
            redBalls.add(num);
        }
        // 生成蓝色球号码
        int blueBall = random.nextInt(16) + 1;

        // 将红色球号码放入ArrayList并排序
        ArrayList<Integer> redBallList = new ArrayList<>(redBalls);
        // 输出结果
        System.out.print("双色球所有号码: " + redBallList);
        redBallList.add(blueBall);
        System.out.println(", " + blueBall + "]");
        System.out.print("红色号码: ");
        for (int red : redBallList.subList(0, 6)) {
            System.out.print(red + " ");
        }
        System.out.println("蓝色号码: " + blueBall);
    }
}